<?php

/**
 * variedad actions.
 *
 * @package    plagas
 * @subpackage variedad
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class variedadActions extends sfActions
{
  public function executeIndex(sfWebRequest $request)
  {
    $this->variedads = Doctrine_Core::getTable('variedad')
      ->createQuery('a')
      ->execute();

    $this->filtro = new variedadFormFilter();
  }

  public function executeFilter(sfWebRequest $request)
{
    $this->setTemplate('index');
    $this->filtro = new variedadFormFilter();
    if($request->isMethod('post'))
    {
        $this->filtro->bind($request->getParameter($this->filtro->getName()));
    }
    $query = $this->filtro->buildQuery($this->filtro->getValues());
    $id = $this->filtro->getValue('cultivo_id');
    if ($id == '')
    {
        $this->variedads = Doctrine_Core::getTable('variedad')
            ->createQuery('a')
            ->execute();
    }
    else
    {
        $this->variedads = $query->execute();
    }
    $this->filtro = new variedadFormFilter();
    }

  public function executeShow(sfWebRequest $request)
  {
    $this->variedad = Doctrine_Core::getTable('variedad')->find(array($request->getParameter('id')));
    $this->forward404Unless($this->variedad);
  }
}
